clear all
load ParEst_eh1_time0_Mex ParEst_eh1_time0_Mex
load trans_time1_age0_eh1_comp1.out
Chute = ParEst_eh1_time0_Mex;
HandleLo = @Principal_A2_n;

Dij=trans_time1_age0_eh1_comp1'; % Read transition moments

Dnf_1	 =	Dij(1);
Dni_1	 =	Dij(2);
Dfn_1	 =	Dij(3);
Dff_1	 =	0;
Dfi_1	 =	Dij(4);
Din_1	 =	Dij(5);
Dii_1	 =	0;
Dif_1  =	Dij(6);
Dni_df_1 = Dij(7);    % Transitions for spouse 2 (spouse) from not working to informal when spouse 1 (head) loses job in formal sector
Dni_di_1 = Dij(8);    % Transitions for spouse 2 (spouse) from not working to informal when spouse 1 (head) loses job in informal sector
Dnf_2	 =	Dij(9);
Dni_2	 =	Dij(10);
Dfn_2	 =	Dij(11);
Dff_2	 =	0;
Dfi_2	 =	Dij(12);
Din_2	 =	Dij(13);
Dii_2	 =	0;
Dif_2  =	Dij(14);
Dni_df_2 = Dij(15);
Dni_di_2 = Dij(16);
Lower =[Dfn_1,Din_1,Dnf_1,Dni_1,Dfi_1,Dif_1,Dfn_2,Din_2,...
     Dnf_2,Dni_2,Dfi_2,Dif_2,Dni_df_2,Dni_di_2,Dni_df_1,Dni_di_1];
LoBo =zeros(1,29);
LoBo = [Lower, 0.1, 0.1, 0.1, 0.1, -10, -2, -10, -10, -2, -10, -10, 0, 0];
HiBo = [.81 .81 .81 .991 .81 .81 .81 .81 .81 .81 .81 .81 .91 .81 .91 .91 10 10 10 10 -4 4 0 0 4 0 0 1 1];
                 options = saoptimset( ...
                     'PlotFcn',{@saplotbestf,@saplottemperature,@saplotf,@saplotbestx,@saplotx},...
                     'TolFun',4000,'ReannealInterval',4, ...
                     'InitialTemperature', 1^2*[1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 10 10 10 10 6 6 10 10 6 10 10 1 1], ...
                     'TemperatureFcn', @temperaturefast, 'StallIterLimit', 1000); %16*10^2* default 'ReannealInterval',6,
[x,fval,exitflag,output]  = simulannealbnd(HandleLo, Chute, LoBo, HiBo, options)
ParEst_eh1_time0_Mex = x;
save ParEst_eh1_time0_Mex ParEst_eh1_time0_Mex
